/**
 * 版权所有：厦门市巨龙软件工程有限公司
 * Copyright 2010 Xiamen Dragon Software Eng. Co. Ltd.
 * All right reserved. 
 *====================================================
 * 文件名称: ChoosePoint.java
 * 修订记录：
 * No    日期				作者(操作:具体内容)
 * 1.    2010-1-6			beralee(创建:创建文件)
 *====================================================
 * 类描述：(说明未实现或其它不应生成javadoc的内容)
 * 
 */
package bera.lee.memorycard;

import java.text.DecimalFormat;
import java.text.Format;
import java.util.ArrayList;
import java.util.HashMap;

import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.AdapterView.OnItemClickListener;

/**
 *<pre>
 * <b><font color="blue">ChoosePoint</font></b>
 * </pre>
 * 
 *<pre>
 * <b>&nbsp;--描述说明--</b>
 * </pre>
 * 
 * <pre></pre>
 * 
 * <pre>
 * <b>--样例--</b>
 *   ChoosePoint obj = new ChoosePoint();
 *   obj.method();
 * </pre>
 * 
 * JDK版本：JDK1.4
 * 
 * @author <b>beralee</b>
 */
public class ChoosePoint extends Activity {
	private DbAdapter mDbHelper;

	private static final int[] allicon = { R.drawable.b1, R.drawable.c3, R.drawable.n4, R.drawable.f1,
			R.drawable.fa1, R.drawable.e1, R.drawable.ct1, R.drawable.p1,R.drawable.ny9,R.drawable.t3,R.drawable.kt10,R.drawable.nb14};

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
		setContentView(R.layout.chooselayout);
		mDbHelper = new DbAdapter(this);
		mDbHelper.open();
		// 绑定Layout里面的ListView
		ListView list = (ListView) findViewById(R.id.chooselist);

		// 生成动态数组，加入数据
		ArrayList<HashMap<String, Object>> listItem = new ArrayList<HashMap<String, Object>>();
		for (int i = 1; i <= Config.CAN_CHOOSE_Point; i++) {

			HashMap<String, Object> map = new HashMap<String, Object>();
			map.put("pointtitle", "Level " + i);
			map.put("pointtitleicon", allicon[i - 1]);
			listItem.add(map);
		}
		// 生成适配器的Item和动态数组对应的元素
		SimpleAdapter listItemAdapter = new SimpleAdapter(this, listItem,// 数据源
				R.layout.list_item_icon_text,// ListItem的XML实现
				// 动态数组与ImageItem对应的子项
				new String[] { "pointtitle", "pointtitleicon" },
				// ImageItem的XML文件里面的一个ImageView,两个TextView ID
				new int[] { R.id.pointtitle, R.id.pointtitleicon });

		// 添加并且显示
		list.setAdapter(listItemAdapter);
		list.setOnItemClickListener(new OnItemClickListener() {

			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
				Config.Point = arg2 + 1;
				MapUtil.configByPoint();
				Intent intent = new Intent();
				intent.setClass(ChoosePoint.this, BitmapTouch.class);
				startActivityForResult(intent, 1);
			}
		});

	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
		super.onActivityResult(requestCode, resultCode, intent);
	
			this.finish();
		
	}

}
